home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dave falkenburg's sprocket / interfaces / sprocket.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  5.3 KB  |  200 lines

  1. /*
  2.     File:        Sprocket.h
  3.  
  4.     Contains:    Prototypes for the “guts” of a Macintosh application.
  5.  
  6.     Written by: Dave Falkenburg
  7.  
  8.     Copyright:    Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/19/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 12/6/94        DRF                Add  “sprocket credits” box resource ID.
  21.                  11/23/94    DRF                Add ToggleCheckBox, a nice little dialog item utility.
  22.                  11/12/94    DRF                AppConditionals.h is now BuildConditionals.h.  Also revised some
  23.                                             QuickDrawGX stuff.
  24.                  11/8/94        DRF                Add prototype for DragDestinationIsTheTrash.
  25.                   9/27/94        DRF                Changed filename to Sprocket.h. Also made scrap coercion
  26.                                              routines more explicit.
  27.                 9/9/94        DRF                Reordered headers and removed redundant #includes.
  28.                 9/4/94        DRF                Added scroll bar constants.
  29.  
  30. */
  31.  
  32. #ifndef        _SPROCKET_
  33. #define        _SPROCKET_
  34.  
  35. #ifndef        _BUILDCONDITIONALS_
  36. #include    "BuildConditionals.h"
  37. #endif
  38.  
  39. #ifndef        __TYPES__
  40. #include    <Types.h>
  41. #endif
  42.  
  43. #ifndef        __WINDOWS__
  44. #include    <Windows.h>
  45. #endif
  46.  
  47. #ifndef        __DIALOGS__
  48. #include    <Dialogs.h>
  49. #endif
  50.  
  51. #ifndef        __STANDARDFILE__
  52. #include    <StandardFile.h>    //    for ModalFilterYDUPP
  53. #endif
  54.  
  55. #ifndef        __DRAG__
  56. #include    <Drag.h>
  57. #endif
  58.  
  59. #include    "Preferences.h"
  60. #include    "Window.h"
  61.  
  62. #if    qUseQuickDrawGX
  63. #include    <FixMath.h>            //    make sure we don’t use GX lame #define of “fixed1”
  64. #include    <graphics types.h>
  65. #endif
  66.  
  67. //    useful macros
  68.  
  69. #if    qDebug
  70. #define    DebugMessage(x)    DebugStr(x)
  71. #else
  72. #define    DebugMessage(x)
  73. #endif
  74.  
  75. //    Resource IDs
  76.  
  77. #define    kErrorAlertID                        128
  78. #define    kStandardCloseAlertID                129
  79. #define    kStandardCloseWithNewPubsAlertID    130
  80.  
  81. #define    kCoreErrorStrings                    128
  82. #define    kUnsupportedSystemSoftware            1
  83. #define    kNeedsThreadManager                    2
  84. #define    kNeedsQuickdrawGX                    3
  85.  
  86. #define    kStandardCloseStrings                129
  87. #define    kQuittingStr                        1
  88. #define    kClosingStr                            2
  89.  
  90. #define    kPreferencesFileStrings                130
  91. #define    kPreferencesFileName                1
  92.  
  93. #define    kSplashPictureID                    128
  94.  
  95. #define    kCreditsBox                            258
  96.  
  97. #if        qUseQuickDrawGX
  98. #define    kUseGraphicsSizeResource        0
  99. #define    kAllowGXToExtendGraphicsHeap    ((gxClientAttribute) 0)
  100. #endif
  101.  
  102. //    Useful constants
  103.  
  104. enum
  105.     {
  106.     kScrollbarWidth = 16,    //    width of a standard Macintosh scrollbar
  107.     kScrollbarTweak = 2        //    left edge = rightedge - kScrollbarWidth + kScrollbarTweak
  108.     };
  109.  
  110. //    Useful functions provided by App:
  111.  
  112. void                    HandleEvent(EventRecord *anEvent);
  113. void                    HandleClose(WindowPtr aWindow);
  114.  
  115. short                    StandardAlert(    short alertID,
  116.                                         short defaultItem                = ok,
  117.                                         short cancelItem                = 0,
  118.                                         ModalFilterUPP customFilterProc    = nil);
  119.  
  120. void                    ErrorAlert(short stringList,short whichString);
  121. void                    FatalErrorAlert(short stringList,short whichString);
  122.  
  123. extern ModalFilterUPP    StandardDialogFilter;
  124. extern ModalFilterYDUPP    StandardDialogFilterYD;
  125. extern void                PseudoClickInDialogItem(DialogPtr theDialog, short itemToClick);
  126. extern Boolean            ToggleCheckBox(DialogPtr theDialog, short theCheckBox);
  127.  
  128. enum    StandardCloseResult
  129.     {
  130.     kSaveDocument = 1,
  131.     kCancelSaveDocument = 2,
  132.     kDontSaveDocument = 3
  133.     };
  134.  
  135. StandardCloseResult        StandardCloseDocument(const StringPtr documentType,StringPtr documentName, Boolean hasNewEditions, Boolean quitting);
  136.  
  137. OSErr                    CheckAppleEventForMissingParams(AppleEvent *theAppleEvent);
  138.  
  139. short                    OpenPreferencesResFile(void);
  140.  
  141. Boolean                    DragDestinationIsTheTrash(DragReference theDrag);
  142.  
  143.  
  144. //    AOCE “FrontWindow”-equivalent routine for the Standard Mail package
  145. extern FrontWindowUPP    FrontWindowProcForAOCEUPP;
  146.  
  147. //    Globals
  148.  
  149. extern    Boolean                gDone;
  150. extern    Boolean                gMenuBarNeedsUpdate;
  151.  
  152. extern    Boolean                gHasColorQuickdraw;
  153. extern    Boolean                gHasThreadManager;
  154. extern    Boolean                gHasDragManager;
  155. extern    Boolean                gHasAOCE;
  156. extern    Boolean                gHasDisplayManager;
  157.  
  158. #if    qInlineInputAware
  159. extern    Boolean                gHasTextServices;
  160. extern    Boolean                gHasTSMTE;
  161. #endif
  162.  
  163. #if    qUseQuickDrawGX
  164. extern    Boolean                gHasQuickDrawGX;
  165. extern    long                gQuickDrawGXVersion;
  166. extern    long                gQuickDrawGXPrintingVersion;
  167. extern    gxGraphicsClient    gQuickDrawGXClient;
  168. #endif
  169.  
  170. extern    GrafPtr                gWindowManagerPort;
  171. extern    Rect                gDeskRectangle;
  172. extern    RgnHandle            gMouseRegion;
  173.  
  174. extern    short                gPreferencesRsrcRefNum;
  175.  
  176.  
  177. /////////////////////////////////////////////////////////////////
  178. //
  179. //    Routines that the application MUST supply:
  180.  
  181.  
  182. //        intialization & tear down
  183. extern    OSErr    SetupApplication(void);
  184. extern    void    TearDownApplication(void);
  185.  
  186. //        menu handling:
  187. extern    void    HandleMenu(TWindow * topWindowObj,long menuCode);
  188.  
  189. //        scrap coercion hooks:
  190. extern    void    WriteLocalClipboardToScrap(void);
  191. extern    void    ReadLocalClipboardFromScrap(void);
  192.  
  193. //        document handling routines:
  194. extern    OSErr    CreateNewDocument(void);
  195. extern    OSErr    OpenDocument(LetterDescriptor *,void *);
  196. extern    OSErr    PrintDocument(LetterDescriptor *,void *);
  197. extern    Boolean    QuitApplication(void);
  198.  
  199. #endif
  200.